"""
    UTM_plusthisis_LCL()

This gives the time difference to be applied
to UTM when deriving local time.
is

   local_time = univ_time + UTM_plusthisis_LCL()
"""
function UTM_plusthisis_LCL()
   raw_millisecs = (now() - now(Base.Dates.UTC)).value
   halfway = copysign(30_000, raw_millisecs)
   raw_millisecs += halfway
   raw_minutes = div(raw_millisecs, 60_000)
   return Minutes( raw_minutes )
end


const UTM2LCL = [ UTM_plusthisis_LCL() ]

function refresh_universal_to_localis()
     UTM2LCL[1] = UTM_plusthisis_LCL()
end

"""
    UTMoffset()

    julia> UTMoffset()
    NanoTimes.Minutes(-240)
"""
function UTMoffset()
	utm = UniversalTime()
	lcl = LocalTime(utm)
	nanosecs = lcl.value - utm.value
	qrtrhours = fld(nanosecs, 900_000_000_000)
	if isodd(qrtrhours)
	    qrtrhours = cld(nanosecs, 900_000_000_000)
	end
	# multiply intx by 15 [minutes]
	# 15 * intx === intx * 16 - intx
	#           === (intx << 4) - intx
    qrtrhours = (qrtrhours << 4) - qrtrhours
	return Minutes( qrtrhours )
end

function UTMoffset(units::T) where T<:NanoTimes.SecondBasedGrain
    minutes = UTMoffset()
    if units === Seconds
        return Seconds(value(minutes) * SECONDS_PER_MINUTE)
    elseif units === Minutes
        return minutes
    elseif units === Hours
        hr, mn = divmod(minutes, MINUTES_PER_HOUR)
        return Hours(hr), Minutes(mn)
    else
	return QuarterHours(div(value(minutes), MINUTES_PER_QUARTERHOUR))
    end
end

function UTMoffset_formatted()
    minutes = value(UTMoffset())
    sgn = signbit(minutes) ? NEGATIVE : POSITIVE
    minutes = abs(minutes)
    hr, mn = divrem(minutes, MINUTES_PER_HOUR)
    hrs = twodigits(abs(hr))
    mns = twodigits(abs(mn))
    return string(sgn, hrs, HMS_SEP, mns)
end

const ZEROHOUR = Base.Dates.Time(0, 0, 0, 0, 0, 0)
